package cn.edu.hunau.pojo;

/**
 * 购物车的条目 (商品和数量的对应关系)
 * @Author 苏佳
 * @Date 2022 11 07 14 21
 **/
public class CarItem {
    private Product product;
    private int qty;

    private int size;

    private double shoppingPrice;



    public double getShoppingPrice() {
        return shoppingPrice;
    }

    public void setShoppingPrice(double shoppingPrice) {
        this.shoppingPrice = shoppingPrice;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public CarItem(Product product, int qty, int size,double shoppingPrice) {
        this.product = product;
        this.qty = qty;
        this.size = size;
        this.shoppingPrice = shoppingPrice;
    }

    public CarItem() {

    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public int getQty() {
        return qty;
    }

    public void setQty(int qty) {
        this.qty = qty;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CarItem carItem = (CarItem) o;
        return carItem.getProduct().getId() == this.getProduct().getId();
    }

    @Override
    public int hashCode() {
        return product.getId();
    }
}
